package com.zemo.base.service.refund.impl;

import com.zemo.base.dao.refund.RefundRecordDao;
import com.zemo.base.domain.entity.refund.RefundRecordEntity;
import com.zemo.base.domain.enums.YnEnum;
import com.zemo.base.service.refund.RefundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: RefundRecordServiceImpl
 * @author: SuperZemo
 * @email: zemochen@gmail.com
 * @Date 17/01/2018 14:16
 * @Description
 */
@Service
public class RefundRecordServiceImpl implements RefundRecordService {

    @Autowired
    private RefundRecordDao refundRecordDao;

    @Override
    public RefundRecordEntity addRecord(RefundRecordEntity entity) {
        refundRecordDao.insert(entity);

        return entity;
    }

    /**
     * 更新退款记录
     * @param entity
     * @return
     */
    @Override
    public RefundRecordEntity update(RefundRecordEntity entity) {
        refundRecordDao.update(entity);
        return entity;
    }

    @Override
    public RefundRecordEntity getByRefundNo(String refundNo,Integer chanelId) {
        RefundRecordEntity entity = new RefundRecordEntity();
        entity.setTradeNo(refundNo);
        entity.setChannelId(chanelId);
        entity.setYn(YnEnum.YES.getCode());
        return refundRecordDao.selectOne(entity);
    }

}
